package nowcoder.written_examination.tencent;

import java.util.Scanner;

/**
 *
 * @author fance
 * @date 2018/7/29 19:21
 */
public class MainI {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String s1 = scanner.next();
            String s2 = new StringBuilder(s1).reverse().toString();
            int[][] dp = new int[s1.length() + 1][s2.length() + 1];
            for (int i = 1; i < dp.length; i++) {
                for (int j = 1; j < dp[0].length; j++) {
                    dp[i][j] = s1.charAt(i - 1) == s2.charAt(i - 1) ?
                            dp[i - 1][j - 1] + 1 : Math.max(dp[i - 1][j], dp[i][j - 1]);
                }
            }
            System.out.println(s1.length() - dp[s1.length()][s2.length()]);
        }
    }
}
   /* public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = scanner.nextInt();
            }
            Arrays.sort(a);
            int max1 = 0;
            int max2 = 0;
            for (int i = 0; i < n; i++) {
                if (a[i] == a[0]) {
                    max1++;
                }
                if (a[i] == a[n - 1]) {
                    max2++;
                }
            }

            int min1 = 0;
            int min2 = 0;
            if (n % 2 != 0) {
                if (Math.abs(a[n / 2 - 1] - a[n / 2]) < Math.abs(a[n / 2] - a[n / 2 + 1])) {
                    for (int i = 0; i < n; i++) {
                        if (a[i] == a[n / 2 - 1]) {
                            min1++;
                        }
                        if (a[i] == a[n / 2]) {
                            min2++;
                        }
                    }
                } else {
                    for (int i = 0; i < n; i++) {
                        if (a[i] == a[n / 2 + 1]) {
                            min1++;
                        }
                        if (a[i] == a[n / 2]) {
                            min2++;
                        }
                    }
                }
            } else {
                for (int i = 0; i < n; i++) {
                    if (a[i] == a[n / 2 + 1]) {
                        min1++;
                    }
                    if (a[i] == a[n / 2]) {
                        min2++;
                    }
                }
            }
            System.out.println(min1 * min2 + " " +  max1 * max2);

        }*/

       /* Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String s = scanner.next();
            StringBuilder stringBuilder = new StringBuilder();
            for (int i = 0; i < s.length(); i++) {
                char c = s.charAt(i);
                if (c - 'a' >= 0 && c - 'a' <= 26) {
                    stringBuilder.append(c);
                }
            }
            for (int i = 0; i < s.length(); i++) {
                char c = s.charAt(i);
                if (c - 'A' >= 0 && c - 'A' <= 26) {
                    stringBuilder.append(c);
                }
            }
            System.out.println(stringBuilder);
        }*/
  /*  }
}
*/